#!/usr/bin/env python3
# coding: utf-8
# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# This file is a part of the CANN Open Software.
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# ======================================================================================================================
api: pytorch
api_type: function_aclnn_grouped_matmul_swiglu_quant
aclnn_api_type: function_pyaclnn_grouped_matmul_swiglu_quant
version: v2.1
name: aclnn.grouped.matmul.swiglu.quant
aclnn_name: GroupedMatmulSwigluQuant
generate: ascend_generate_grouped_matmul_swiglu_quant
standard:
    acc: 
        single_bm
inputs:
  - name: x
    type: tensor
    required: true
    dtypes:
        values: [int8]
    shapes:
        dim_numbers:
            values: [2]
        dim_values:
            values: [1, 7, 8, 9, 15, 16, 17, 19, 20, 21, 255, 256, 257, 13107, [1, 1024]]
    ranges:
        valid:
            values: [[-128, 127]]
            random_types:
                - name: nd
        invalid:
            values: [[-inf], [inf], [nan]]
  - name: weight
    type: tensor
    required: true
    dtypes:
        values: [int8]
    shapes:
        dim_numbers:
            values: [5]
        dim_values:
            values: [1, 7, 8, 9, 15, 16, 17, 19, 20, 21, 255, 256, 257, 13107, [1, 1024]]
    ranges:
        valid:
            values: [[-128, 127]]
            random_types:
                - name: nd
        invalid:
            values: [[-inf], [inf], [nan]]
  - name: bias # 不支持参数, 不进行泛化
    type: tensor
    required: true
    dtypes:
        values: [int32]
    shapes:
        dim_numbers:
            values: [2]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [[-inf], [inf], [nan]]
  - name: offset # 不支持参数, 不进行泛化
    type: tensor
    required: true
    dtypes:
        values: [fp32]
    shapes:
        dim_numbers:
            values: [2]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [0]
        invalid:
            values: [[-inf], [inf], [nan]]
  - name: weightScale
    type: tensor
    required: true
    dtypes:
        values: [fp32, fp16, bf16]
    shapes:
        dim_numbers:
            values: [2]
        dim_values:
            values: [1, 7, 8, 9, 15, 16, 17, 19, 20, 21, 255, 256, 257, 13107, [1, 1024]]
    ranges:
        valid:
            values: [[-1, 1]]
            random_types:
                - name: nd
        invalid:
            values: [[-inf], [inf], [nan]]
  - name: xScale
    type: tensor
    required: true
    dtypes:
        values: [fp32]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1, 7, 8, 9, 15, 16, 17, 19, 20, 21, 255, 256, 257, 13107, [1, 1024]]
    ranges:
        valid:
            values: [[-1, 1]]
            random_types:
                - name: nd
        invalid:
            values: [[-inf], [inf], [nan]]
  - name: groupList # 特殊参数, 在标杆内泛化
    type: tensor
    required: true
    dtypes:
        values: [int64]
    shapes:
        dim_numbers:
            values: [1]
        dim_values:
            values: [1]
    ranges:
        valid:
            values: [[-inf, inf]]
            random_types:
                - name: nd
        invalid:
            values: [[-inf], [inf], [nan]]
  - name: seed # 随机种子 不参与计算
    type: attr
    dtypes:
        values: [ int ]
    ranges:
        valid:
            values: [[0, 10000000]]  
        invalid:
            values: [[0, 10000000]]
  - name: case # 用例指示器, 例如为 1 的话 用例入参就泛化成 case 1 的形状
    type: attr
    dtypes:
        values: [ int ]
    ranges:
        valid:
            values: [0, 1, 2, 3]
        invalid:
            values: [0, 1, 2, 3]
  - name: format
    type: attr
    required: false
    dtypes:
        values: [ non_param ]
    ranges:
        valid:
            values: [ "FRACTAL_NZ"]
        invalid:
            values: [ "FRACTAL_NZ" ]